package com.fg.pro.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fg.pro.sys.dao.SysDeptDao;
import com.fg.pro.model.sys.entity.SysDept;
import com.fg.pro.sys.service.SysDeptService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 部门(SysDept)表服务实现类
 *
 * @author makejava
 * @since 2025-07-17 10:10:47
 */
@Service("sysDeptService")
public class SysDeptServiceImpl extends ServiceImpl<SysDeptDao, SysDept> implements SysDeptService {

    @Override
    public List<SysDept> getTree() {
        List<SysDept> list = query().eq("dept_lev",1).list();
        for (SysDept sysDept : list) {
            List<SysDept> childrenList = query().eq("dept_parent_id", sysDept.getId()).list();
            sysDept.setChildren(childrenList);
        }
        return list;
    }
}

